package com.test.gwt.mvp.client.factory;

import com.google.gwt.place.shared.PlaceController;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.SimpleEventBus;
import com.google.web.bindery.event.shared.testing.CountingEventBus;
import com.test.gwt.mvp.client.ui.MailDetailView;
import com.test.gwt.mvp.client.ui.MailDetailViewImpl;
import com.test.gwt.mvp.client.ui.MailListView;
import com.test.gwt.mvp.client.ui.MailListViewImpl;
import com.test.gwt.mvp.client.ui.MainScreen;
import com.test.gwt.mvp.client.ui.MainScreenImpl;

//L’implémentation de ClientFactory avec les vues comme singletons
public class ClientFactoryImpl implements ClientFactory {
	// Le bus global d’événements
	private static final EventBus eventBus = new CountingEventBus(
			new SimpleEventBus());
	// Le contrôleur de navigation
	private static final PlaceController placeController = new PlaceController(
			eventBus);
	private static final MailListView mailListView = new MailListViewImpl();
	private static final MailDetailView mailDetailView = new MailDetailViewImpl();
	private static final MainScreen mainMenuView = new MainScreenImpl();

	@Override
	public EventBus getEventBus() {
		return eventBus;
	}

	@Override
	public PlaceController getPlaceController() {
		return placeController;
	}

	@Override
	public MailListView getMailListView() {
		return mailListView;
	}

	@Override
	public MailDetailView getMailDetailView() {
		return mailDetailView;
	}

	@Override
	public MainScreen getMainScreenView() {
		return mainMenuView;
	}
}
